home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Environments / Clean 1.2.4 / PowerMacInterface / dialogs.icl < prev    next >
Encoding:
Modula Implementation  |  1996-03-01  |  5.5 KB  |  155 lines  |  [TEXT/3PRM]

  1. implementation module dialogs;
  2.  
  3. import mac_types;
  4.  
  5. ::    ProcPtr :== Int;
  6.  
  7. //    Initialization
  8.  
  9. InitDialogs :: !ProcPtr !Toolbox -> Toolbox;
  10. InitDialogs resumeProc t = code (resumeProc=D0,t=U)(z=Z){
  11.     call    .InitDialogs
  12. };
  13.  
  14. //    Creating and Disposing of Dialogs
  15.  
  16. NewDialog :: !Ptr !Rect !{#Char} !Bool !Int !WindowPtr !Bool !Int !Handle !Toolbox -> (!DialogPtr, !Toolbox);
  17. NewDialog dStorage (left,top,right,bottom) title visible procID behind goAwayFlag refCon items t 
  18. = code (right=W,bottom=W,left=W,top=W,dStorage=D0,title=O0D1SD2,visible=D3,procID=D4, 
  19.     behind=D5,goAwayFlag=D6,refCon=D7,items=A0,t=U) (dialog=D0,z=I8Z)
  20. {
  21.     instruction 0x92E1FFF8    |    stw    r23,-8(sp)
  22.     call    .NewDialog
  23. };
  24.  
  25. NewCDialog :: !Ptr !Rect !{#Char} !Bool !Int !WindowPtr !Bool !Int !Handle !Toolbox -> (!DialogPtr,!Toolbox);
  26. NewCDialog dStorage (left,top,right,bottom) title visible procID behind goAwayFlag refCon items t
  27. = code (right=W,bottom=W,left=W,top=W,dStorage=D0,title=O0D1SD2,visible=D3,procID=D4,
  28.     behind=D5,goAwayFlag=D6,refCon=D7,items=A0,t=U) (dialog=D0,z=I8Z)
  29. {
  30.     instruction 0x92E1FFF8    |    stw    r23,-8(sp)
  31.     call    .NewColorDialog
  32. };
  33.  
  34. CloseDialog :: !DialogPtr !Toolbox -> Toolbox;
  35. CloseDialog theDialog t = code (theDialog=D0,t=U)(z=Z){
  36.     call    .CloseDialog
  37. };
  38.  
  39. DisposDialog :: !DialogPtr !Toolbox -> Toolbox;
  40. DisposDialog theDialog t = code (theDialog=D0,t=U)(z=Z){
  41.     call    .DisposeDialog
  42. };
  43.  
  44. //    Handling Dialog Events
  45.  
  46. ModalDialog :: !ProcPtr !DialogPtr !Toolbox -> (!Int,!Toolbox);
  47. ModalDialog filterProc dialog t = code (filterProc=R2D0,dialog=O0D1U,t=U)(itemHit=W,z=Z){
  48.     call    .ModalDialog
  49. };
  50.  
  51. IsDialogEvent :: !(!Int,!Int,!Int,!Int,!Int,!Int) !Toolbox -> (!Bool,!Toolbox);
  52. IsDialogEvent event tb = IsDialogEvent1 event;
  53.  
  54. IsDialogEvent1 :: !(!Int,!Int,!Int,!Int,!Int,!Int) -> (!Bool,!Toolbox);
  55. IsDialogEvent1 (what,message,when,h,v,modifiers) = code (modifiers=W,h=W,v=W,when=L,message=L,what=W)(result=D0,z=I16Z){
  56.     instruction 0x38610000    |    addi    r3,sp,0
  57.     call    .IsDialogEvent
  58.     instruction    0x70630001    |    andi.    r3,r3,1
  59.     instruction    0x7C6300D0    |    neg        r3,r3
  60. };
  61.  
  62. DialogSelect :: !(!Int,!Int,!Int,!Int,!Int,!Int) !Toolbox -> (!Bool,!DialogPtr,!Int,!Toolbox);
  63. DialogSelect r t = DialogSelect1 r;
  64.  
  65. DialogSelect1 :: !(!Int,!Int,!Int,!Int,!Int,!Int) -> (!Bool,!DialogPtr,!Int,!Toolbox);
  66. DialogSelect1 (what,message,when,h,v,modifiers) = code (modifiers=W,h=W,v=W,when=L,message=L,what=W)(result=D0,theDialog=L,itemHit=W,z=I16Z){
  67.     instruction 0x3821FFFA    |    subi    sp,sp,6
  68.     instruction 0x38610006    |    addi    r3,sp,6
  69.     instruction 0x38810000    |    addi    r4,sp,0
  70.     instruction 0x38A10004    |    addi    r5,sp,4
  71.     call    .DialogSelect
  72.     instruction    0x70630001    |    andi.    r3,r3,1
  73.     instruction    0x7C6300D0    |    neg        r3,r3
  74. };
  75.                                       
  76. //    Invoking Alerts
  77.  
  78. //    Manipulating Items in Dialogs and Alerts
  79.  
  80. GetDItem :: !DialogPtr !Int !Toolbox -> (!Int,!Handle,!Rect,!Toolbox);
  81. GetDItem theDialog itemNo tb
  82.     =    (itemType,item,(left,top,right,bottom),NewToolbox);
  83.     {
  84.         (itemType,item,right,bottom,left,top) = GetDItem1 theDialog itemNo tb
  85.     };
  86.  
  87. GetDItem1 :: !DialogPtr !Int !Toolbox -> (!Int,!Handle,!Int,!Int,!Int,!Int);
  88. GetDItem1 theDialog itemNo t = code (theDialog=R14D0,itemNo=D1,t=O0D2O2D3O6D4U)(itemType=W,item=L,right=W,bottom=W,left=W,top=W){
  89.     call    .GetDialogItem
  90. };
  91.  
  92. SetIText :: !Handle !{#Char} !Toolbox -> Toolbox;
  93. SetIText item text t = code (item=D0,text=SD1,t=U)(z=Z){
  94.     call    .SetDialogItemText
  95. };
  96.  
  97. GetIText :: !Handle !{#Char} !Toolbox -> (!{#Char},!Toolbox);
  98. GetIText item text tb = (GetIText1 item text tb, NewToolbox);
  99.  
  100. GetIText1 :: !Handle !{#Char} !Toolbox -> {#Char};
  101. GetIText1 item text t = code (item=D0,text=U,t=U)(new_text=A0){
  102.     instruction 0x3AA00000    |    li        r21,0
  103.     instruction 0x92B70004    |    stw        r21,4(r23)
  104.     instruction 0x38970007    |    addi    r4,r23,7
  105.     call    .GetDialogItemText
  106. };
  107.  
  108. SelIText :: !DialogPtr !Int !Int !Int !Toolbox -> Toolbox;
  109. SelIText theDialog itemNo strtSel endSel t = code (theDialog=D0,itemNo=D1,strtSel=D2,endSel=D3,t=U)(z=Z){
  110.     call    .SelectDialogItemText
  111. };
  112.  
  113. OutlineButtonFunction :: ProcPtr;
  114. OutlineButtonFunction = code ()(function_address=D0){
  115.     call    .myoutlinebuttonfunction
  116. }
  117.  
  118. DisposeRoutineDescriptor :: !ProcPtr !Toolbox -> Toolbox;
  119. DisposeRoutineDescriptor proc_ptr t = code (proc_ptr=D0,t=U)(z=Z){
  120.     call    .DisposeRoutineDescriptor
  121. }
  122.  
  123. /*
  124. DialogFilterFunction :: ProcPtr;
  125. DialogFilterFunction = code ()(function_address=D0){
  126.     instruction 0x41FA 0x0006            |                lea    l2(pc),a0
  127.     instruction 0x2008                    |               move.l    a0,d0
  128.     instruction 0x6046                    |                bra.s    l3:
  129.     instruction 0x2017                    |   l2:            move.l    (sp),d0
  130.     instruction 0x508F                    |               addq.l    #8,sp
  131.     instruction 0x205F                    |               move.l    (sp)+,a0
  132.     instruction 0x2257                    |               move.l    (sp),a1
  133.     instruction 0x2E80                    |               move.l    d0,(sp)
  134.     instruction 0x0C50 0x0006            |                 cmp.w    #6,(a0)
  135.     instruction 0x670E                    |                beq.s    update
  136.     instruction 0x0C50 0x0003            |                  cmp.w    #3,(a0)
  137.     instruction 0x6714                    |                beq.s    key_down
  138.     instruction 0x4251                    |   ret_false:    clr.w    (a1)
  139.     instruction 0x426F 0x0004            |                  clr.w    4(sp)
  140.     instruction 0x4E75                    |                rts
  141.     instruction 0x32BC 0xFFFF            |      update:        move.w    #-1,(a1)
  142.     instruction 0x3F7C 0xFFFF 0x0004    |                move.w    #-1,4(sp)
  143.     instruction 0x4E75                    |                 rts
  144.     instruction 0x1028 0x0005              |    key_down:    move.b    5(a0),d0
  145.     instruction 0x0C00 0x000D           |                  cmp.b    #13,d0
  146.     instruction 0x6706                     |                beq.s    return_key
  147.     instruction 0x0C00 0x0003           |                  cmp.b    #3,d0
  148.     instruction 0x66DC                     |                 bne.s    ret_false
  149.     instruction 0x32BC 0x0001           |    return_key:    move.w    #1,(a1)
  150.     instruction 0x3F7C 0xFFFF 0x0004    |                move.w    #-1,4(sp)
  151.     instruction 0x4E75                  |                 rts
  152.                                         | l3:
  153. };
  154. */
  155.